package com.wowo.dao;

import com.wowo.entity.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.Date;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/db/applicationContext.xml")
public class UserDaoTest2 {
    @Autowired
    UserDao userDao;
    @Test
    public void insertUserTest(){
        userDao.insertUser(new User("king",23,new Date(),"sdgg"));
    }
    @Test
    public void selectUserById(){
        User user = userDao.getUserById(49);
        System.out.println(user);
    }

    @Test
    public void updateUser(){
        User user = new User("qwsf",20,new Date(),"das");
        user.setId(51);
        userDao.updateUser(user);
    }
    @Test
    public void deleteUser(){
        userDao.deleteUser(44);

    }
    @Test
    public void getAll(){
        List<User> users = userDao.getAll();
        System.out.println(users);
    }
}
